{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% block title %}{{'admin.user.manage.user_role.fields.heading_title'|trans}}{% endblock %}
{% block body %}

<form id="user-roles-form" class="form-horizontal" method="post" action="{{ url('admin_user_roles', {id:user.id}) }}" data-currentuser="{{ app.user.id }}" data-edituser="{{ user.id }}">
  <div class="checkboxs" id="old-checkboxs">
    {% set admin_roles = get_admin_roles() %}
    {% for role in admin_roles if (role.code in app.user.roles or role.createdUserId == app.user.id) or 'ROLE_SUPER_ADMIN' in app.user.roles %}
      <label>
        <input type="checkbox" name="roles[]" value="{{role.code}}" {% if role.code in user.roles %}checked="checked"{% endif %}>{{role.name}}
      </label>
    {% endfor %}
  </div>

  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>
{% endblock %}

{% block footer %}
  <button id="change-user-roles-btn" data-submiting-text="{{'form.btn.submit.submiting'|trans}}" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#user-roles-form"  data-user="{{default.user_name|default('role.student'|trans)}}" >{{'form.btn.save'|trans}}</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">{{'form.btn.cancel'|trans}}</button>
  
  <script>app.load('user/roles-modal');</script>
{% endblock %}